home *** CD-ROM | disk | FTP | other *** search
/ SuperHack / SuperHack CD.bin / CODING / CPP / ACGIFREE.ZIP / INCLUDE / A_SCART.H < prev    next >
Encoding:
C/C++ Source or Header  |  1996-08-14  |  2.2 KB  |  66 lines

  1. //a_Shopping Cart related objects
  2.  
  3. ////////////////////////////////////////////////////////////////////////////////
  4. // ASCartItem - AShoppingCart item
  5. ////////////////////////////////////////////////////////////////////////////////
  6. class ASCartItem : public APairItem
  7. {
  8.   public:
  9.     ASCartItem(ASCartItem *psciSource = NULL);
  10.     virtual ~ASCartItem();
  11.  
  12.     //a_Declares debug/dump related functions
  13.     #ifdef _DEBUG_DUMP_
  14.       void dump(void);     //a_Debugging dump, when _DEBUG_DUMP_ is set
  15.     #endif
  16.  
  17.     //a_ABaseElement pure virtual override
  18.     virtual void doOut(AStreamOutput *pasOut) const;
  19.  
  20.     //a_Quantity control
  21.     int  sciGetQuantity(void) const     { return m_iQuantity; }
  22.     void sciSetQuantity(int iNewQ)      { m_iQuantity = iNewQ; }
  23.     ASCartItem &operator ++(void)       { assert(m_iQuantity < INT_MAX); m_iQuantity++; return *this; }
  24.     ASCartItem &operator --(void)       { if (m_iQuantity > 0x00) m_iQuantity--; return *this; }
  25.     ASCartItem &operator +=(int iAddQ);
  26.  
  27.   protected:
  28.     //a_Copy function
  29.     void _bCopy(const ASCartItem &sciSource);
  30.  
  31.     int m_iQuantity;                         //a_How many of these
  32. };
  33.  
  34. ///////////////////////////////////////////////////////////////////////////////////
  35. // AShoppingCart class
  36. ///////////////////////////////////////////////////////////////////////////////////
  37. class AShoppingCart : public APairList
  38. {
  39.   public:
  40.     AShoppingCart(AShoppingCart *pscSource = NULL);
  41.     virtual ~AShoppingCart();
  42.  
  43.     //a_Declares debug/dump related functions
  44.     #ifdef _DEBUG_DUMP_
  45.       void dump(void);     //a_Debugging dump, when _DEBUG_DUMP_ is set
  46.     #endif
  47.  
  48.     //a_Used by all children of the ABaseElement (the family heirloom of sorts :)
  49.     virtual void doOut(AStreamOutput *pasOut) const;
  50.  
  51.     //a_Cart info
  52.     void        ascSetCartName(const char *pccName);
  53.     const char *ascGetCartName(void) const { return m_pcCartName; }
  54.  
  55.     //a_Use a PairList and get items specific to this cart
  56.     int ascFindCartItems(const APairList &plSource);
  57.  
  58.     //a_Maintenance
  59.     ASCartItem *ascAddCartItem(const char *pccItemName, int iQuantity = 0x1);
  60.  
  61.   protected:
  62.     void _bCopy(const AShoppingCart &scSource);
  63.  
  64.     char *m_pcCartName;
  65. };
  66.